package chapter7;
import static utility.Print.*;

/**
 * Exercise 5: (1) Create two classes, A and B, with default constructors (empty
 * argument lists) that announce themselves. Inherit a new class called C from
 * A, and create a member of class B inside C. Do not create a constructor for
 * C. Create an object of class C and observe the results.
 */

class A {
	private int intA;
	private String stringA;
	@Override
    public String toString() {
	    return "A [intA=" + intA + ", stringA=" + stringA + "]";
    }
	public A(int intA, String stringA) {
		print("Calling the constructor for A");
		this.intA = intA;
		this.stringA = stringA;
		print(this.toString());
	}
}

class B {
	private String name;

	@Override
    public String toString() {
	    return "B [name=" + name + "]";
    }

	public B(String name) {
		print("Calling the constructor for B");
		this.name = name;
		print(this.toString());
    }
	
}

/**
 * @author rDiaconescu
 *
 */
class C extends A{
	B b;

	public C(int intA, String stringA, String bName) {
	    super(intA, stringA);
	    // TODO Auto-generated constructor stub
	    b = new B(bName);
    }

	@Override
    public String toString() {
		return "C [b=" + b + "]";
    }
	
}

public class Exercise5 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		C c = new C(13, "asd", "bname");
		
		print(c.toString());

	}

}
